using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniAspNetCore
{
    /// <summary>
    /// web主机
    /// </summary>
    public class WebHost : IWebHost
    {
        /// <summary>
        /// 监听服务
        /// </summary>
        private readonly IServer _server;
        /// <summary>
        /// 请求处理管道
        /// </summary>
        private readonly RequestDelegate _handler;

        public WebHost(IServer server, RequestDelegate handler)
        {
            _server = server;
            _handler = handler;
        }

        /// <summary>
        /// 开启服务
        /// </summary>
        /// <returns></returns>
        public Task StartAsync() => _server.StartAsync(_handler);
    }
}
